
#ifndef _TRANSPORTLAYER_H_
#define _TRANSPORTLAYER_H_

using namespace std;



#include <mutex>
#include <queue>
#include <memory>
#include <vector>
#include <functional>
#include <initializer_list>
#include <condition_variable>
#include "dataTransmissionDds.hpp"



#define ZEROCOPY_MOD 0
class transportLayer
{
public:
    using AsyncFuncType = std::function<void (const void *data, const size_t size)>;

public:
    static std::shared_ptr<DataTransmissionDds> create(const int type = ZEROCOPY_MOD);
    virtual ~transportLayer() = default;
    virtual int init(const std::initializer_list<void *> attr = {});
    virtual int transmit(const void *data,const size_t size)  = 0;
    int transmit(const std::vector<uint8_t> &data);
    virtual void ayncRecv(const void *data,const size_t size);
    bool wait(const int64_t timeout = 5000);
    size_t available();
    void *take();
    virtual void release(const void *item) = 0;
protected:
    transportLayer() = default;
protected:
    std::mutex m_queMutex;
    std::condition_variable m_queCond;
    std::queue<void *> m_recvQue;
    static const size_t m_queMaxSize;

};


#endif // _MESSDATA_PUBLISHER_H_